<?php

function buildTreeCategoryOption($catData, $prentsID = 0) {
    $specs = '&nbsp;';
    foreach ($catData as $aCat) {

        if ($aCat['category_parent'] == $prentsID) {
            if($aCat['category_level'] == 0){
                $style = 'style=color:#F58516;';
            }
            if ($aCat['category_level'] == 1) {
                $specs = '&nbsp;&nbsp;&nbsp;';
            }
            if ($aCat['category_level'] == 2) {
                $specs = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            }
            if ($aCat['category_level'] == 3) {
                $specs = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            }
            $catList .= "<option value=" . $aCat['category_id'] . "  $style>" . $specs . $aCat['category_name'] . "</option>";
            $catList .= buildTreeCategoryOption($catData, $aCat['category_id']);
        }
    }
    return $catList;
}

$strCatOption = buildTreeCategoryOption($aryCategory);
?>
<div>
    Danh mục sản phẩm liên quan
</div>
<div>
    <span>
        <select name="product_category_id" id="product_category_id" class="w200p">
            <option value="0">Danh mục liên quan</option>
            <?php echo $strCatOption; ?>
        </select>
    </span>
    <span>
        <input type="button" class="submit" value="Lưu" onclick="AdminController.editNewsProductCategory('<?php echo $parentCategoryId;?>');">
    </span>
</div>
<input type="hidden" id="news_category_id" name="news_category_id" value="<?php echo $parentCategoryId;?>">